package com.cn.yunhe.struts.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class TransactionInterceptor extends AbstractInterceptor{
	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		// TODO :insert/update/delete开头的方法，必须经过事务过滤器
		System.out.println("事务校验         开始 ");
		String methName=invocation.getProxy().getMethod();
		if (methName.startsWith("insert")||methName.startsWith("update")||methName.startsWith("delete")) {
			System.out.println("追加数据库事务");
			
		}
		String result=invocation.invoke();
		System.out.println("事务校验        结束");
		return result;
	}

}
